/*
A Manager to construct a QuadTree from an SCML datafile and given a time to update it.
Updating means 
*/

#ifndef SPRMANAGER_H
#define SPRMANAGER_H

#include <string>
#include <map>
#include <SFML/System/Time.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <string>

#include "Quad.h"
#include "SprQuad.h"
#include "BoneQuad.h"
#include "SCMLpp.h"

class SprManager
{
public:
	SprManager();
	SprManager(const std::string& dataFile);

	void				loadAnimDataFromFile(const std::string& data);
	Quad*				createQuadTree();
	void				updateQuadTree(sf::Time dt, Quad* QuadRoot);

	int					getAnimation() const;
	void				setAnimation(int i);

	void				setFPS(float fps);
	float				getFPS() const;
	
private:

	inline float		lerp(float a, float b, float f){ return a + (b - a)*f; }
	sf::Transform		transformLerp(const sf::Transform& origin, const sf::Transform& goal, float f); //NOT IMPLEMENTED
	int					getCurrentKeyId(sf::Time time);
	int					getNextKeyId();

	

private:

	std::map<int,Quad::Ptr>			mCreatedQuads;

	SCML::Data						mData;
	int								mCurrentEntity;
	int								mCurrentAnimation;

	float							mFPS; //Frames per Second

	int								mCurrentKey; //is the keyId of the origin key for animation to goal key
	int								mNextKey; // goalkey

	sf::Time						mTimelineTime;
};

#endif

